package com.du.fileload.framework.config;

import com.du.fileload.framework.entity.ResourcePathNameFormatENUM;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * 全局配置文件
 */
@Component
@ConfigurationProperties(prefix = "fileload")
public class DFileLoad {


    //全局缓存实例
    private static DFileLoad GlobalDFileLoad;

    public static DFileLoad getInstance(){
        return GlobalDFileLoad;
    }

    public DFileLoad(){
        if(DFileLoad.GlobalDFileLoad==null)
            DFileLoad.GlobalDFileLoad=this;
    }

    private static String configPath;


    /**
     * 资源访问是否需要经过授权
     */
    private boolean auth;

    /**
     * 授权用户列表  第一个是root账号
     */
    private List<String> authUsers;

    /**
     * 资源访问前缀
     */
    private String requestPrefix="/dresource";

    /**
     * 资源文件路径
     */
    private String resourcePath;

    /**
     * 资源文件缓存路径
     */
    private String resourceTempPath;


    /**
     * 存储目录格式化
     */
    private ResourcePathNameFormatENUM resourcePathNameFormat=ResourcePathNameFormatENUM.DATE;

    /**
     * 压缩配置
     */
    private DFileCompress compress;


    public boolean isAuth() {
        return auth;
    }

    public void setAuth(boolean auth) {
        this.auth = auth;
    }

    public String getConfigPath() {
        return configPath;
    }

    public void setConfigPath(String configPath) {
        this.configPath = configPath;
    }

    public String getRequestPrefix() {
        return requestPrefix;
    }

    public void setRequestPrefix(String requestPrefix) {
        this.requestPrefix = requestPrefix;
    }

    public String getResourcePath() {
        return resourcePath;
    }

    public void setResourcePath(String resourcePath) {
        this.resourcePath = resourcePath;
    }

    public String getResourceTempPath() {
        return resourceTempPath;
    }

    public void setResourceTempPath(String resourceTempPath) {
        this.resourceTempPath = resourceTempPath;
    }

    public ResourcePathNameFormatENUM getResourcePathNameFormat() {
        return resourcePathNameFormat;
    }

    public void setResourcePathNameFormat(ResourcePathNameFormatENUM resourcePathNameFormat) {
        this.resourcePathNameFormat = resourcePathNameFormat;
    }

    public List<String> getAuthUsers() {
        return authUsers;
    }

    public void setAuthUsers(List<String> authUsers) {
        this.authUsers = authUsers;
    }

    public  DFileCompress getCompress() {
        return compress;
    }

    public void setCompress(DFileCompress compress) {
        this.compress = compress;
    }

}
